package config

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/layout"
	"go-CodeToolUi/components/config/right_content_config"
)

var YouJieGou = rightStructure()
var YouCenterBody = binding.NewString()

var layoutContainer *fyne.Container

func rightStructure() fyne.CanvasObject {
	layoutContainer = container.New(layout.NewVBoxLayout(), right_content_config.GetAllRightContent()...)
	YouCenterBody.AddListener(binding.NewDataListener(func() {
		get, err := YouCenterBody.Get()
		if err != nil || get == "" {
			return
		}
		//隐藏所有
		right_content_config.HideAllRightContent()
		//显示指定
		right_content_config.GetRightContent(get).Show()
	}))
	scroll := container.NewVScroll(layoutContainer)
	return scroll
}
